package com.fitz.config;

import com.fitz.enums.SerializerEnum;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 原先设计时服务提供方和消费方分开了
 * @author fitz 2020-5-18 17:44
 */
@Deprecated
@Configuration
public class RpcProviderConfiguration{

    @Value("${fitz.rpc.provider.server-port}")
    private int serverPort;

    @Value("${fitz.rpc.provider.registry-address}")
    private String registryAddress;

    @Value("${fitz.rpc.consumer.serializer-type}")
    private String serializerType = SerializerEnum.HESSIAN2.getType();

    @Bean
    public ProviderInitializer initializer(){

        SerializerEnum serializer = null;
        serializer = SerializerEnum.find(serializerType);
        if (serializer == null){
            serializer = SerializerEnum.HESSIAN2;
        }
        return new ProviderInitializer(serverPort,registryAddress,serializer.getCode());
    }
}
